<%@ page language="java" import="java.sql.*" contentType="text/html;charset=UTF-8" %>


<HTML>
<HEAD>
<TITLE>▒▒ 게시판 ▒▒</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
  .table {font-size:9pt; font-family : 돋움 ;font-weight:bold;color:white;background:#6699CC; }
a {text-decoration: none; }
  td	{ font-size : 10pt ; font-family : 돋움 ; font-decoration : none ;}
  font	{ font-size : 10pt ; font-family : 돋움 ; font-decoration : none ; }
  #title{ font-size : 10pt ; font-family : 돋움 ; font-decoration : none ; font-weight : bold ; color : ffffff ;}
 .dform { font-family: 돋움 ; font-size:10pt;color:white;background:#6699CC;}
 .ldTable { border-bottom:#636363 solid 1px;border-color:white; padding-top:5px; padding-bottom:5px; padding-left:3px;
            padding-right:3px; font-size:9pt}
-->
</style>

<script language="javascript">
function saveit() {
    if(document.form.name.value.length==0){
        alert("이름을 써주세요..");
        form.name.focus();
        return;
    }
    if(document.form.title.value.length==0){
        alert("제목을 써주세요..");
        form.title.focus();
        return;
    }
    if(document.form.content.value.length==0){
        alert("내용을 써주세요..");
        form.content.focus();
        return;
    }
    if(document.form.pwd.value.length==0){
        alert("수정/삭제에 필요한 비밀번호을 써주세요..");
        form.pwd.focus();
        return;
    }
    document.form.submit();
}
</script>

</HEAD>
<BODY bgcolor="#FFFFFF">

<%	
int intIdx = Integer.parseInt(request.getParameter("idx"));

String DB_URL = "jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=utf8";
String DB_USER = "root";
String DB_PASSWORD = "root";

Connection conn = null;
Statement stmt = null;
ResultSet result = null;

String sName="", sEmail="", sTitle="", sContent="";

Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
stmt = conn.createStatement();
String query = "SELECT NAME,EMAIL,TITLE,CONTENT FROM GUEST WHERE IDX="+intIdx;

result = stmt.executeQuery(query);

if(result.next()){
	sName = result.getString(1);
	sEmail = result.getString(2);
	sTitle = result.getString(3);
	sContent = result.getString(4);
}

result.close();
stmt.close();
conn.close();
 
%>


<CENTER>
<FONT size=2><B> 게시판 글수정 </B></FONT>
</CENTER>
<HR><P>

<FORM name="form" method="GET" action="modifyproc.jsp" >
  <table width="500" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="#FFFFFF">
    <tr>
      <td colspan="3" height="290" >
	<table width="500" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
  	<tr>
  	</tr>
	</table>
        <table border="0" cellspacing="1" width="500" cellpadding="1" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
          <tr>
            <td width="93" height="030" align="center" bgcolor="#8EA2FF"><font face="돋움" size="2" color="#FFFFFF"><strong>글쓴이</strong></font></td>
            <td width="400" height="030" align="left" style="padding-left: 20; padding-right: 30" bgcolor="#F6F6F6">
              <input type="text" name="name" size="20" style="border: 1 dashed" value="<%=sName%>"><!-- 여기 -->
            </td>
          </tr>
          <tr>
            <td width="93" height="030" align="center" bgcolor="#8EA2FF"><font face="돋움" size="2" color="#FFFFFF"><strong>E-mail</strong></font></td>
            <td width="400" height="030" align="left" style="padding-left: 20; padding-right: 30" bgcolor="#F6F6F6">
              <input type="text" name="email" size="30" style="border: 1 dashed" value="<%=sEmail%>"><!-- 여기 -->
            </td>
          </tr>
          <tr>
            <td width="93" height="030" align="center" bgcolor="#8EA2FF"><font face="돋움" size="2" color="#FFFFFF"><strong>제목</strong></font></td>
            <td width="400" height="030" align="left" style="padding-left: 20; padding-right: 30" bgcolor="#F6F6F6">
              <input type="text" name="title" size="30"  style="border-left: 1px dashed; border-right: 1 dashed; border-top: 1 dashed; border-bottom: 1 dashed"  value="<%=sTitle%>"><!-- 여기 -->
            </td>
          </tr>          
          <tr>
            <td width="93" align="center" bgcolor="#8EA2FF"><font face="돋움" size="2" color="#FFFFFF"><strong>내용</strong></font></td>
            <td width="400" align="left" style="padding-left: 20;  padding-top: 5; padding-bottom: 5" bgcolor="#F6F6F6">
              <textarea name="content" cols='55' rows='10' style="border: 1 dashed"><%=sContent%></textarea><!-- 여기 -->
            </td>
          </tr>
          <tr>
            <td width="93" height="030" align="center" bgcolor="#8EA2FF"><font face="돋움" size="2" color="#FFFFFF"><strong>비밀번호</strong></font></td>
            <td width="400" height="030" align="left" style="padding-left: 20; padding-right: 30" bgcolor="#F6F6F6">
              <input type="password" name="pwd" size="16" style="border: 1 dashed">
              &nbsp; <font face="돋움" size="2" color="#8EA2FF">[수정시 필요]</font></td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
  		<input type="hidden" name=idx value="<%=intIdx%>"><!-- 여기 -->
  <p align="center">
  <table>
	  <tr>
	  	<td>
	  		<a href="list.jsp"><img src="image/list.gif" border="0"></a>	  		
	  	</td>
	  	<td>
	  	</td>
	  	<td>
	  		<a href="JavaScript:saveit()"><img src="image/export.gif" border="0"></a>
	  	</td>
	  </tr>
  </table>
  </p>

</FORM>

</BODY>
</HTML>